package com.example.studyroom.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.studyroom.Entity.Reservation;
import com.example.studyroom.dto.StudyRoomAdmin.HandleReservationDTO;
import com.example.studyroom.dto.User.UserReserveDTO;
import com.example.studyroom.mapper.ReservationMapper;
import com.example.studyroom.service.ReservationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReservationServiceImpl extends ServiceImpl<ReservationMapper, Reservation> implements ReservationService {

    //用户预约自习室
    @Override
    public void UserReserve(Reservation reservation) {
        baseMapper.UserReserve(reservation);
    }

    @Autowired
    private ReservationMapper reservationMapper;

    //用户查看我的预约
    @Override
    public List<UserReserveDTO> getReservationByUser(String Uname){
        return reservationMapper.getReservationByUser(Uname);
    }

    //用户取消预约
    @Override
    public void cancelReservation(Integer id){
        reservationMapper.cancelReservation(id);
    }

    //显示该管理员所负责的自习室的所有预约
    @Override
    public List<HandleReservationDTO> getReservationByAdmin(String adminName){
        return reservationMapper.getReservationByAdmin(adminName);
    }

    //自习室管理员审核预约
    @Override
    public void handleReservation(Integer id){
        reservationMapper.handleReservation(id);
    }
}
